package com.richie696.account.dao;

import com.richie696.account.domain.Account;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface AccountDAO extends JpaRepository<Account, String>, JpaSpecificationExecutor<Account> {

    @Query("from Account")
    List<Account> selectAllByJpql();

    @Query("from Account where cardNo = ?1")
    Account selectOneJpql(String cardNo);

    @Query(value = "select * from account", nativeQuery = true)
    List<Account> selectAllBySql();

    @Query(value = "select * from account where card_no = ?1", nativeQuery = true)
    Account selectOneSql(String cardNo);

    List<Account> findByNameLike(String name);

    List<Account> findByNameLikeAndMoneyGreaterThanEqual(String name, Double money);

}
